package util;

import java.io.Reader;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.*;

public class MyBatisUtil {

    private static SqlSessionFactory sqlMapper;

    static {
        try {
            Reader reader = Resources.getResourceAsReader("util/MyBatisConfig.xml");
            sqlMapper = new SqlSessionFactoryBuilder().build(reader);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static SqlSession getSession() {
        return sqlMapper.openSession();
    }
}
